﻿using AutoMapper;
using CollegeSim.Domain.DTO;
using CollegeSim.Domain.Entities;

namespace CollegeSim.Domain
{
    // Author: Ryan Redburn
    // Project: CollegeSim
    // Date: 5/13/2014

    /// <summary>
    /// Creates type maps for CollegeSim domain.
    /// </summary>
    public static class DomainMapConfig
    {
        /// <summary>
        /// Create type maps.
        /// </summary>
        public static void Initialize()
        {
            // Course
            Mapper.CreateMap<Course, CourseDTO>();

            // Semester
            Mapper.CreateMap<Semester, SemesterDTO>();

            // SchoolYear
            Mapper.CreateMap<SchoolYear, SchoolYearDTO>();

            // Session
            Mapper.CreateMap<Session, SessionDTO>()
                .ForMember(dto => dto.Course, opt => opt.MapFrom(s => Mapper.Map<CourseDTO>(s.Course)))
                .ForMember(dto => dto.Instructor, opt => opt.MapFrom(s => Mapper.Map<InstructorDTO>(s.Instructor)))
                .ForMember(dto => dto.Semester, opt => opt.MapFrom(s => Mapper.Map<SemesterDTO>(s.Semester)))
                .ForMember(dto => dto.SchoolYear, opt => opt.MapFrom(s => Mapper.Map<SchoolYearDTO>(s.SchoolYear)));

            // Instructor
            Mapper.CreateMap<Instructor, InstructorDTO>();

            // Student
            Mapper.CreateMap<Student, StudentDTO>();
        }
    }
}
